package cz.myslivec.knihovna.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name="BOOK_COPY")
//@SequenceGenerator(name="BOOK_COPY_SEQ", sequenceName="BOOK_COPY_SEQ", allocationSize = 1)
public class BookCopy implements Serializable {
	private static final long serialVersionUID = 2591897121878679269L;

	@Id
	@Column(name = "BCOP_ID")
	@GeneratedValue(strategy=GenerationType.AUTO)
	private long id;

	private String bookCode;
	
	@ManyToOne
	@JoinColumn(name="TIT_ID")
	private Title title;
	
	private String note;

	
	// GET & SET
	public String getBookCode() {
		return bookCode;
	}

	public void setBookCode(String bookCode) {
		this.bookCode = bookCode;
	}

	public Title getTitle() {
		return title;
	}

	public void setTitle(Title title) {
		this.title = title;
	}

	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	public long getId() {
		return id;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (id ^ (id >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		BookCopy other = (BookCopy) obj;
		if (id != other.id)
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "BookCopy [id=" + id + ", bookCode=" + bookCode + ", title="
				+ title + ", note=" + note + "]";
	}
	
}
